package com.unittec.zk.provider.auth.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.unittec.zk.provider.auth.entity.SysDepart;
import com.unittec.zk.sdk.auth.domain.SysDepartDto;
import com.unittec.zk.sdk.auth.domain.SysUserRes;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @description 部门Tree实体类
 * @author chengjie
 * @date 2019/10/21
 */
@Data
@Accessors(chain = true)
public class SysDepartTree implements Serializable {

    private static final long serialVersionUID = -3684453499402155574L;

    /** 对应SysDepart中的id字段,前端数据树中的key */
    private String key;

    /** 对应SysDepart中的id字段,前端数据树中的value */
    private String value;

    /** 对应depart_name字段,前端数据树中的title */
    private String title;

    private boolean isLeaf;

    private String id;

    private String parentId;

    private String departName;

    private String departNameEn;

    private String departNameAbbr;

    private Integer departOrder;

    private String departDescription;

    private String orgType;

    private String orgCode;

    private String phone;

    private String fax;

    private String address;

    private String memo;

    private String status;

    private String delFlag;

    private String appId;

    private String tenantId;

    private String createUser;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    private String modifyUser;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date modifyTime;

    /**
     * 用户类型 (1=管网采集，2=运维巡检)
     */
    private String userType;

    private List<SysUserRes> userResList;

    private List<SysDepartTree> children = new ArrayList<SysDepartTree>();

    public SysDepartTree() {

    }

    /**
     * 将SysDepart对象转换成SysDepartTree对象
     *
     * @param sysDepart
     */
    public SysDepartTree(SysDepart sysDepart) {
        this.key = sysDepart.getId();
        this.value = sysDepart.getId();
        this.title = sysDepart.getDepartName();
        this.id = sysDepart.getId();
        this.parentId = sysDepart.getParentId();
        this.departName = sysDepart.getDepartName();
        this.departNameEn = sysDepart.getDepartNameEn();
        this.departNameAbbr = sysDepart.getDepartNameAbbr();
        this.departOrder = sysDepart.getDepartOrder();
        this.departDescription = sysDepart.getDepartDescription();
        this.orgType = sysDepart.getOrgType();
        this.orgCode = sysDepart.getOrgCode();
        this.phone = sysDepart.getPhone();
        this.fax = sysDepart.getFax();
        this.address = sysDepart.getAddress();
        this.memo = sysDepart.getMemo();
        this.status = sysDepart.getStatus();
        this.delFlag = sysDepart.getDelFlag();
        this.appId = sysDepart.getAppId();
        this.tenantId = sysDepart.getTenantId();
        this.createUser = sysDepart.getCreateUser();
        this.createTime = sysDepart.getCreateTime();
        this.modifyUser = sysDepart.getModifyUser();
        this.modifyTime = sysDepart.getModifyTime();
    }

    /**
     * 将SysDepartDto对象转换成SysDepartTree对象
     *
     * @param sysDepartDto
     */
    public SysDepartTree(SysDepartDto sysDepartDto) {
        this.key = sysDepartDto.getId();
        this.value = sysDepartDto.getId();
        this.title = sysDepartDto.getDepartName();
        this.id = sysDepartDto.getId();
        this.parentId = sysDepartDto.getParentId();
        this.departName = sysDepartDto.getDepartName();
        this.departNameEn = sysDepartDto.getDepartNameEn();
        this.departNameAbbr = sysDepartDto.getDepartNameAbbr();
        this.departOrder = sysDepartDto.getDepartOrder();
        this.departDescription = sysDepartDto.getDepartDescription();
        this.orgType = sysDepartDto.getOrgType();
        this.orgCode = sysDepartDto.getOrgCode();
        this.phone = sysDepartDto.getPhone();
        this.fax = sysDepartDto.getFax();
        this.address = sysDepartDto.getAddress();
        this.memo = sysDepartDto.getMemo();
        this.status = sysDepartDto.getStatus();
        this.delFlag = sysDepartDto.getDelFlag();
        this.appId = sysDepartDto.getAppId();
        this.tenantId = sysDepartDto.getTenantId();
        this.createUser = sysDepartDto.getCreateUser();
        this.createTime = sysDepartDto.getCreateTime();
        this.modifyUser = sysDepartDto.getModifyUser();
        this.modifyTime = sysDepartDto.getModifyTime();
        this.userResList = sysDepartDto.getUserResList();
        this.userType=sysDepartDto.getUserType();
    }

}
